//
//  RacksCollectionHeaderView.m
//  danpin
//
//  Created by chuangjia on 2/12/2015.
//  Copyright © 2015 chuangjia. All rights reserved.
//

#import "RacksCollectionHeaderView.h"
#import "ZShare.h"
#import "AOTag.h"
#import "viewconfig.h"
@interface RacksCollectionHeaderView()<AOTagDelegate>
{
    
}
@property (nonatomic, strong) AOTagList *tagList;
@property(nonatomic,strong) UIView *bgView;
@end

@implementation RacksCollectionHeaderView
- (id)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor=[UIColor clearColor];
        _bgView =[[UIView alloc] initWithFrame:self.bounds];
        _bgView.backgroundColor=[UIColor clearColor];
        [self addSubview:_bgView];
        _tagList = [[AOTagList alloc] initWithFrame:CGRectMake(0, 0, DEVICE_WIDTH-PHOTO_FRAME_WIDTH, 80)];
        _tagList.backgroundColor =[UIColor clearColor];
        _tagList.delegate=self;
        [_bgView addSubview:_tagList];
    }
    return self;
}

-(void)dealloc
{
    self.bgView =nil;
    self.tagList.delegate =nil;
    self.tagList=nil;
    self.actionBlock=nil;
    //  NSLog(@"%s", __PRETTY_FUNCTION__);
}
-(void)setCallBack:(void(^)(UIView*,id,id))callback
{
    self.actionBlock =callback;
}
/// 根据数据模型来显示内容
- (void)showInfo:(id)model indexPath:(NSIndexPath *)indexPath
{
    NSArray *tagAr =(NSArray *)model;
    [self.tagList removeAllTag];
    
    float fTop = [self.tagList addTags:tagAr limitLine:3 type:@"menuView"];
    _tagList.frame =CGRectMake(PHOTO_TIME_PADDING, PHOTO_TIME_PADDING, DEVICE_WIDTH-PHOTO_FRAME_WIDTH,fTop);
    [self layoutSubviews];
}
/// 返回Cell高度
+ (CGFloat)returnCellHeight:(id)model
{
    NSArray *tagAr =(NSArray *)model;
    AOTagList *tc = [[AOTagList alloc] initWithFrame:CGRectMake(PHOTO_TIME_PADDING,PHOTO_TIME_PADDING, DEVICE_WIDTH-PHOTO_FRAME_WIDTH, 80)];
    float fTop = [tc addTags:tagAr limitLine:3 type:@"menuView"];
    tc=nil;
    return fTop+PHOTO_FRAME_WIDTH;
}
- (void)tagDidSelectTag:(AOTag *)tag
{
    if (self.actionBlock) {
        self.actionBlock(self,tag.tTitle,nil);
    }
}
@end
